package org.ktpro.shortlink.admin.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.ktpro.shortlink.admin.common.convention.result.Result;
import org.ktpro.shortlink.admin.remote.dto.ShortLinkFeignRemoteService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Url标题控制层
 */
@RestController(value = "urlTitleControllerByAdmin")
@Slf4j
@RequiredArgsConstructor
public class UrlTitleController {

    private final ShortLinkFeignRemoteService shortLinkFeignRemoteService;

    /**
     * 获取url对应的标题
     */
    @GetMapping("/api/short-link/admin/v1/title")
    public Result<String> getTitleByUrl(@RequestParam("url") String url) {
        return shortLinkFeignRemoteService.getTitleByUrl(url);
    }
}
